﻿// -------------------------------------------------------------------------------------------------
// <copyright file="Person.cs" company="HeterogeneousComputing.com">
// Creative Commons Attribution-ShareAlike 3.0 Unported License
// </copyright>
//
// <author>Jock</author>
//
// <date>05/08/2011</date>
//
// <summary>Implements the person class</summary>
// -------------------------------------------------------------------------------------------------
namespace TheTVDBScraper
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization; 
    using System.Text;

    /// -------------------------------------------------------------------------------------------------
    /// <summary>   A class representing a Person or Individual.  </summary>
    /// <remarks>    The class author was Jock, on the 05/08/2011. </remarks>
    /// -------------------------------------------------------------------------------------------------
    public class Person
    {
        #region Private Fields
            /// <summary> The name of the Actor. </summary>
            private string name;

            /// <summary> The URL of an image for this Actor. </summary>
            private string image;

            /// <summary> The unique identifier for the Actor. </summary>
            private string id;

            /// <summary> The job roles this person performs. </summary>
            private List<JobRole> jobRoles = new List<JobRole>();
        #endregion

        #region Constructors
            /// -------------------------------------------------------------------------------------------------
            /// <summary>   Initializes a new instance of the Person class. </summary>
            /// <param name="name"> The Actors name. </param>
            /// -------------------------------------------------------------------------------------------------
            public Person(string name)
            {
                this.name = name;
            }

            /// -------------------------------------------------------------------------------------------------
            /// <summary>   Prevents a default instance of the Person class from being created. </summary>
            /// -------------------------------------------------------------------------------------------------
            private Person()
            {
            }
        #endregion

        #region Public Properties
            /// -------------------------------------------------------------------------------------------------
            /// <summary>   Gets or sets the Person's name. </summary>
            /// <value> The Persons name. </value>
            /// -------------------------------------------------------------------------------------------------
            [DataMember]
            public string Name
            {
                get
                {
                    return this.name;
                }

                set
                {
                    this.name = value;
                }
            }

            /// -------------------------------------------------------------------------------------------------
            /// <summary>   Gets the JobRoles undertaken by this Person. </summary>
            /// <value> The job roles. </value>
            /// -------------------------------------------------------------------------------------------------
            public List<JobRole> JobRoles
            {
                get
                {
                    return this.jobRoles;
                }
            }
        #endregion

        #region Internal Properties
            /// -------------------------------------------------------------------------------------------------
            /// <summary>   Gets the Person's unique identifier. </summary>
            /// <value> The identifier. </value>
            /// -------------------------------------------------------------------------------------------------
            internal string Id
            {
                get
                {
                    return this.id;
                }
            }

            /// -------------------------------------------------------------------------------------------------
            /// <summary>   Gets the URL for the Person's image. </summary>
            /// <value> The image URL. </value>
            /// -------------------------------------------------------------------------------------------------
            internal string Image
            {
                get
                {
                    return this.image;
                }
            }
        #endregion

        #region Internal Operations

            /// -------------------------------------------------------------------------------------------------
            /// <summary>   Adds a JobRole e.g. Actor to this Person.  </summary>
            /// <remarks>    The method author was Jock, on the 05/08/2011. </remarks>
            /// <param name="newRole">  The new role to add. </param>
            /// -------------------------------------------------------------------------------------------------
            internal void AddJobRole(JobRole newRole)
            {
                bool containsJobRole = false;
                foreach (var jobRole in this.jobRoles)
                {
                    if (jobRole.GetType().Equals(newRole.GetType()))
                    {
                        break;
                    } 
                }

                if (containsJobRole == false)
                {
                    this.jobRoles.Add(newRole);
                }
            }
        #endregion
    }
}

/// -------------------------------------------------------------------------------------------------
// End of Person.cs
/// -------------------------------------------------------------------------------------------------
